/*
 * #%L
 * java model
 * %%
 * Copyright (C) 2009 - 2011 prefabware.com Stefan Isele
 * %%
 * All Rights Reserved.
 * This program is dual-licensed under the GNU General Public license
 * or a commercial license.
 * You may select to use one or the other of these licenses.
 * To obtain a commercial license please contact Stefan Isele at www.stefan-isele.de
 * Any modifications to this file must keep this entire header intact.
 * Redistribution, except as permitted by the selected license, is prohibited.
 * #L%
 */
package com.prefabware.jmodel.annotation;

import com.prefabware.jmodel.code.JCodeOptions;
import com.prefabware.jmodel.expression.literal.JArrayLiteral;

public class JAnnotationValueArray extends JAnnotationValue<JArrayLiteral> {

	public JAnnotationValueArray(String name, JArrayLiteral literal) {
		super(name,literal);
	}
	
	@Override
	public String asCode(JCodeOptions options) {
		//suppress null or empty arrays in annotation values
		Object[] value = this.getLiteral().getObject();
		if (value==null||value.length==0) {
			return null;
		}
		return this.getName() + " = " + this.getLiteral().asCode(options);
	}
}
